<?php
/*
 * Created on Mar 1, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
require_once APPPATH."models/model_dao.php";
class Model_career extends Model_dao {
	function Model_career() {
		// Call the Model constructor
		parent::Model_dao("tbl_career");
	}
	
	function find($id){
		if (intval($id)) {
			$query = $this->db->get_where($this->_tbl_name, array ('id' => $id));

			if ($query->num_rows() > 0) {
				return $query->first_row('array');
			}
		}
		return null;
	}
	
	function findAll(){
		$this->db->order_by("created_date", "desc"); 
		$query = $this->db->get($this->_tbl_name);
		
		$list = $query->result_array();
		if(!empty($list)){
			return $list;
		}
		return false;
	}
	
	function insert_career($data){
		$data['created_date'] = date('Y-m-d h:i:s');
		return $this->insert($data);
	}
	
	function update_career($data,$id){
		if(intval($id)>0){
			$this->db->where('id', $id);
			$result = $this->db->update($this->_tbl_name, $data);
			return $result;
		}
	}
	
	function delete_career($id){
		if (intval($id)) {
            $this->db->where('id', $id);
			$this->db->delete($this->_tbl_name);
		}
	}
}
?>
